package com.imooc.spark

import org.apache.spark.sql.SQLContext
import org.apache.spark.{SparkConf, SparkContext}

object SQLContextApp {
  def main(args: Array[String]): Unit = {
    //1) 创建相应的Context
    val sparkConf = new SparkConf()
    sparkConf.setAppName("SQLContextApp").setMaster("local[*]")

    val sc = new SparkContext(sparkConf)
    val sqlContext = new SQLContext(sc)

    //2）相关的处理
    val path = "D:\\development\\spark-2.4.4-bin-hadoop2.6\\examples\\src\\main\\resources\\people.json"
    val people = sqlContext.read.format("json").load(path)
    people.printSchema()
    people.show()
    //3）关闭资源
    sc.stop()
  }
}
